package ca.cbc.giscommon.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

@Entity
@Table(name = "twitter_user")
@org.hibernate.annotations.Entity(
        selectBeforeUpdate = true,
        dynamicInsert = true, dynamicUpdate = true)
public class TwitterUser implements Cloneable, Serializable {

    private static final long serialVersionUID = -5985830401613301893L;
    private String screenName;
    private String userName;
    private String avatarURL;
    private boolean cbcAccount;

    public TwitterUser() {
    }

    public TwitterUser(String screenName, String userName, String avatarURL) {
        this.setScreenName(screenName);
        this.setUserName(userName);
        this.setAvatarURL(avatarURL);
    }

    @Override
    public TwitterUser clone() throws CloneNotSupportedException {
        return (TwitterUser) super.clone();
    }

    public boolean equals(Object obj) {
        if (obj.getClass().equals(TwitterUser.class) && ((TwitterUser) obj).getScreenName() == this.getScreenName()) {
            return true;
        }
        return false;
    }

    @Column(name = "user_name")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Column(name = "avatar_url")
    public String getAvatarURL() {
        return avatarURL;
    }

    public void setAvatarURL(String avatarURL) {
        this.avatarURL = avatarURL;
    }

    @Id
    @Column(name = "screen_name")
    public String getScreenName() {
        return screenName;
    }

    @Column(name = "cbc_account")
    public boolean isCbcAccount() {
        return cbcAccount;
    }

    public void setCbcAccount(boolean cbcAccount) {
        this.cbcAccount = cbcAccount;
    }

    public void setScreenName(String screenName) {
        this.screenName = screenName;
    }

    public String toString() {
        return new StringBuffer("TwitterUser {screenName:").append(screenName).append(", userName:")
                .append(userName).append(", avatar_url:").append(avatarURL)
                .append(", cbcAccount:").append(cbcAccount).append("}")
                .toString();
    }
}
